<?php
declare(strict_types=1);

namespace LowCode\Naive;


use LowCode\Naive;
use LowCode\Node;
use LowCode\Support\JsExp;
use LowCode\Traits\Events\HasOnClear;
use LowCode\Traits\Props\HasClearable;
use LowCode\Traits\Props\HasColor;
use LowCode\Traits\Props\HasCount;
use LowCode\Traits\Props\HasDefaultValue;
use LowCode\Traits\Props\HasReadonly;
use LowCode\Traits\Props\HasSize;
use LowCode\Traits\Props\HasValueModel;

/**
 * Rate评分组件
 * @method static static make(int|JsExp $default = null) Rate组件
 */
class Rate extends Naive
{

    use HasReadonly, HasColor, HasClearable, HasSize, HasDefaultValue, HasCount, HasValueModel;

    use HasOnClear;

    /**
     * 默认值
     * @param int|JsExp|null $default
     */
    public function __construct(int|JsExp $default = null)
    {
        parent::__construct();
        !is_null($default)&&$this->defaultValue($default);
    }

    /**
     * 允许只激活一半图标
     * @param bool|JsExp $bool
     * @return $this
     */
    public function allowHalf(bool|JsExp $bool = true): static
    {
        return $this->prop('allowHalf', $bool);
    }

    /**
     * 变量信息 this.index
     * @param Node $node
     * @param array $params
     * @return $this
     */
    public function slotDefault(Node $node, array $params = ["index"]): static
    {
        return parent::slotDefault($node,$params);
    }
}
